﻿using jisuanqi;
using System;
using System.Windows.Forms;

namespace function.jisuanqi
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }

        private string temp;
        private operation o = null;

        private void button12_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 7
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 8
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 9
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;
            temp = (sender as Button).Text;
        }

        /// <summary>
        /// /
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button16_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            o = operation_factory.create_operation("/");
            o.NumberA = Convert.ToDouble(temp);
        }

        /// <summary>
        /// 4
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 5
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button5_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 6
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button6_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// *
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button15_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            o = operation_factory.create_operation("*");
            o.NumberA = Convert.ToDouble(temp);
        }

        /// <summary>
        /// 1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button7_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 2
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button8_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// 3
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button9_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            temp = (sender as Button).Text;
        }

        /// <summary>
        /// -
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button14_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;
            o = operation_factory.create_operation("-");
            o.NumberA = Convert.ToDouble(temp);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;
        }

        /// <summary>
        /// +
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button13_Click(object sender, EventArgs e)
        {
            this.textBox1.Text += (sender as Button).Text;

            o = operation_factory.create_operation("+");
            o.NumberA = Convert.ToDouble(temp);
        }

        /// <summary>
        /// =
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button17_Click(object sender, EventArgs e)
        {
            o.NumberB = Convert.ToDouble(temp);
            this.textBox1.Text = o.get_result().ToString();
        }

        /// <summary>
        /// c
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button21_Click(object sender, EventArgs e)
        {
            this.textBox1.Text = "";
            temp = "";
            o = null;
        }

        private void button20_Click(object sender, EventArgs e)
        {
            //this.textBox1.Text += (sender as Button).Text;

            //o = operation_factory.create_operation("16to10");
            temp = this.textBox1.Text;

            this.textBox1.Text = System.Convert.ToInt32(temp.ToString(), 16).ToString();
        }

        private void button19_Click(object sender, EventArgs e)
        {
            temp = this.textBox1.Text;

            this.textBox1.Text = System.Convert.ToInt32(temp.ToString()).ToString("X");
        }
    }
}